﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
//Transform助手类
//静态类只能包含静态成员,不能创建对象
public static class TransformHelper
{
    /// <summary>
    /// 对每一个子物体执行操作,包括自己,包括子子物体
    /// </summary>
    /// <param name="root"></param>
    /// <param name="action"></param>
    public static void ForEveryChild(Transform root, Action<Transform> action)
    {
        action(root);
        if (root.childCount > 0)
        {
            int childCount = root.childCount;
            for (int i = 0; i < childCount; i++)
            {
                ForEveryChild(root.GetChild(i), action);
            }
        }
    }
}